package cn.stylefeng.guns.sys.config;

import cn.stylefeng.guns.sys.core.minio.MinioProperties;
import cn.stylefeng.guns.sys.core.minio.MinioTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Minio配置类,注入template模板类, yml配置minio相关属性
 *
 * @author zhushengjie
 * @date 2022-08-16
 * @see cn.stylefeng.guns.sys.core.minio.MinioProperties
 */
@Configuration(proxyBeanMethods = false)
public class MinioConfig {

    @Bean
    @ConditionalOnMissingBean({MinioTemplate.class})
    @ConditionalOnProperty(
            prefix = "minio",
            name = {"enable"},
            havingValue = "true",
            matchIfMissing = true
    )
    public MinioTemplate minioTemplate(MinioProperties minioProperties) {
        return new MinioTemplate(minioProperties);
    }

}
